﻿using System;
using System.Activities;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WFExtended.Twitter.Activities.Designers;

namespace WFExtended.Twitter.Activities
{
    /// <summary>
    /// Retrieve the information for the saved search represented by the given id.
    /// </summary>
    [ToolboxBitmapAttribute(typeof(EntryPoint), "Resources.SavedSearchToolbox.bmp")]
    [Designer(typeof(SavedSearchIDDesigner))]
    [Description("Retrieve the information for the saved search represented by the given id.")]
    public class GetSavedSearch : TwitterOperationInvoker<SavedSearch>
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="GetSavedSearch"/> class.
        /// </summary>
        public GetSavedSearch()
            :base("GetSavedSearch")
        {}

        /// <summary>
        /// The ID of the saved search.
        /// <remarks>
        /// Required Argument
        /// </remarks>
        /// </summary>
        /// <value>
        /// The ID of the saved search.
        /// </value>
        [Browsable(true)]
        [Category("Parameters")]
        [RequiredArgument]
        [Description("The ID of the saved search.")]
        public InArgument<string> ID { get; set; }

        /// <summary>
        /// Caches the metadata.
        /// </summary>
        /// <param name="metadata">The metadata.</param>
        protected override void CacheMetadata(System.Activities.NativeActivityMetadata metadata)
        {
            RuntimeArgument idArgument = new RuntimeArgument("ID", typeof(string), ArgumentDirection.In, true);
            metadata.Bind(ID, idArgument);
            metadata.AddArgument(idArgument);

            base.CacheMetadata(metadata);
        }

        /// <summary>
        /// Executes the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        protected override void Execute(System.Activities.NativeActivityContext context)
        {
            Parameters.Clear();

            Parameters.Add("id", ID);

            base.Execute(context);
        }

    }
}
